11"""
2- Copyright (c) 2017, 2019 , Oracle Corporation and/or its affiliates. All rights reserved.
2+ Copyright (c) 2017, 2020 , Oracle Corporation and/or its affiliates. All rights reserved.
33Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44"""
55import os
@@ -23,6 +23,7 @@ class ModelContext(object):
2323 __ORACLE_HOME_TOKEN = '@@ORACLE_HOME@@'
2424 __WL_HOME_TOKEN = '@@WL_HOME@@'
2525 __DOMAIN_HOME_TOKEN = '@@DOMAIN_HOME@@'
26+ __JAVA_HOME_TOKEN = '@@JAVA_HOME@@'
2627 __CURRENT_DIRECTORY_TOKEN = '@@PWD@@'
2728 __TEMP_DIRECTORY_TOKEN = '@@TMP@@'
2829
@@ -501,10 +502,11 @@ def has_token_prefix(self, path):
501502 :return: true if the path begins with a known prefix, false otherwise
502503 """
503504 return path .startswith (self .__ORACLE_HOME_TOKEN ) or \
504- path .startswith (self .__WL_HOME_TOKEN ) or \
505- path .startswith (self .__DOMAIN_HOME_TOKEN ) or \
506- path .startswith (self .__CURRENT_DIRECTORY_TOKEN ) or \
507- path .startswith (self .__TEMP_DIRECTORY_TOKEN )
505+ path .startswith (self .__WL_HOME_TOKEN ) or \
506+ path .startswith (self .__DOMAIN_HOME_TOKEN ) or \
507+ path .startswith (self .__JAVA_HOME_TOKEN ) or \
508+ path .startswith (self .__CURRENT_DIRECTORY_TOKEN ) or \
509+ path .startswith (self .__TEMP_DIRECTORY_TOKEN )
508510
509511 def replace_tokens (self , resource_type , resource_name , attribute_name , resource_dict ):
510512 """
@@ -532,6 +534,12 @@ def replace_tokens(self, resource_type, resource_name, attribute_name, resource_
532534 self .get_domain_home (), class_name = self ._class_name , method_name = '_replace_tokens' )
533535 resource_dict [attribute_name ] = attribute_value .replace (self .__DOMAIN_HOME_TOKEN ,
534536 self .get_domain_home ())
537+ elif attribute_value .startswith (self .__JAVA_HOME_TOKEN ):
538+ message = "Replacing {0} in {1} {2} {3} with {4}"
539+ self ._logger .fine (message , self .__JAVA_HOME_TOKEN , resource_type , resource_name , attribute_name ,
540+ self .get_domain_home (), class_name = self ._class_name , method_name = '_replace_tokens' )
541+ resource_dict [attribute_name ] = attribute_value .replace (self .__JAVA_HOME_TOKEN ,
542+ self .get_java_home ())
535543 elif attribute_value .startswith (self .__CURRENT_DIRECTORY_TOKEN ):
536544 cwd = path_utils .fixup_path (os .getcwd ())
537545 message = "Replacing {0} in {1} {2} {3} with {4}"
@@ -561,6 +569,8 @@ def replace_token_string(self, string_value):
561569 result = _replace (string_value , self .__WL_HOME_TOKEN , self .get_wl_home ())
562570 elif string_value .startswith (self .__DOMAIN_HOME_TOKEN ):
563571 result = _replace (string_value , self .__DOMAIN_HOME_TOKEN , self .get_domain_home ())
572+ elif string_value .startswith (self .__JAVA_HOME_TOKEN ):
573+ result = _replace (string_value , self .__JAVA_HOME_TOKEN , self .get_java_home ())
564574 elif string_value .startswith (self .__CURRENT_DIRECTORY_TOKEN ):
565575 result = _replace (string_value , self .__CURRENT_DIRECTORY_TOKEN , path_utils .fixup_path (os .getcwd ()))
566576 elif string_value .startswith (self .__TEMP_DIRECTORY_TOKEN ):
@@ -582,6 +592,7 @@ def tokenize_path(self, path):
582592 wl_home = path_utils .fixup_path (self .get_wl_home ())
583593 domain_home = path_utils .fixup_path (self .get_domain_home ())
584594 oracle_home = path_utils .fixup_path (self .get_oracle_home ())
595+ java_home = path_utils .fixup_path (self .get_java_home ())
585596 tmp_dir = path_utils .fixup_path (tempfile .gettempdir ())
586597 cwd = path_utils .fixup_path (os .path .dirname (os .path .abspath (__file__ )))
587598
@@ -594,6 +605,8 @@ def tokenize_path(self, path):
594605 result = my_path .replace (domain_home , self .__DOMAIN_HOME_TOKEN )
595606 elif oracle_home is not None and my_path .startswith (oracle_home ):
596607 result = my_path .replace (oracle_home , self .__ORACLE_HOME_TOKEN )
608+ elif java_home is not None and my_path .startswith (java_home ):
609+ result = my_path .replace (java_home , self .__JAVA_HOME_TOKEN )
597610 elif my_path .startswith (cwd ):
598611 result = my_path .replace (cwd , self .__CURRENT_DIRECTORY_TOKEN )
599612 elif my_path .startswith (tmp_dir ):
0 commit comments